package com.thientan.controller

import java.util.Map;

import com.thientan.model.HopDong
import com.thientan.service.InMaVachService
import com.thientan.utils.Constants
import com.thientan.utils.Utility

class InMaVachController extends HopDongController{
	InMaVachService inMaVachService
	
	@Override
	public Object getDomainService() {
		return inMaVachService
	}
	
	@Override
	protected String getExportFileName(){
		"PhieuThuMaVach"
	}
	
	@Override
	protected Map buildExportData(Map exportParams){
		String barcodeBasePath = servletContext.getRealPath("") + File.separator;
		String barcodePath = barcodeBasePath + Constants.BARCODE_FILE_PATH
		Long hopDongId = params['id'] as Long
		// Collect hopDong infor to export Phieu Thu
		HopDong hopDong = HopDong.get(hopDongId)
		String maHopDong = hopDong?.maHd ?: ""
		// Generate barcode
		Utility.generateBarcode(maHopDong, barcodePath)
		// Prepare data for export
		
		return ['data' : [],
				'mavachpath' : barcodePath
				]
	}
}
